import axios from 'axios';
import { getDictData ,getCountry,getProvince} from '@/api/index';

let dictUtil = {

};

// 获取常用的数据字典保存至vuex
dictUtil.initDictData = function (vm) {
    axios.get(getDictData + "sex").then(res => {
        if(res.success){
            vm.$store.commit("setSex", res.result);
        }
    });
    axios.get(getDictData + "message_type").then(res => {
        if(res.success){
            vm.$store.commit("setMessageType", res.result);
        }
    });
    axios.get(getDictData + "priority").then(res => {
        if(res.success){
            vm.$store.commit("setPriority", res.result);
        }
    });
    axios.get(getDictData + "leave_type").then(res => {
        if(res.success){
            vm.$store.commit("setLeaveType", res.result);
        }
    });
    axios.get(getDictData + "industry").then(res => {
        if(res.success){
            vm.$store.commit("setIndustry", res.result);
        }
    });
    axios.get(getDictData + "scale").then(res => {
        if(res.success){
            vm.$store.commit("setScale", res.result);
        }
    });
    axios.get(getDictData + "nature").then(res => {
        if(res.success){
            vm.$store.commit("setNature", res.result);
        }
    });
    axios.get(getDictData + "levels").then(res => {
        if(res.success){
            vm.$store.commit("setLevels", res.result);
        }
    });

    axios.get('/highset/country/getAll').then(res => {
        if(res.success){
            vm.$store.commit("setCountry", res.result);
        }
    });

    axios.get('/highset/province/getAll').then(res => {
        if(res.success){
            vm.$store.commit("setProvince", res.result);
        }
    });
    axios.get(getDictData + "contactType").then(res => {
        if(res.success){
            vm.$store.commit("setContactType", res.result);
        }
    });

    axios.get(getDictData + "followLabel").then(res => {
        if(res.success){
            vm.$store.commit("setFollowLabel", res.result);
        }
    });
    axios.get(getDictData + "visitResult").then(res => {
        if(res.success){
            vm.$store.commit("setVisitResult", res.result);
        }
    });
    axios.get(getDictData + "noChanceReason").then(res => {
        if(res.success){
            vm.$store.commit("setNoChanceReason", res.result);
        }
    });

    axios.get(getDictData + "period").then(res => {
        if(res.success){
            vm.$store.commit("setPeriod", res.result);
        }
    });
    axios.get(getDictData + "contactSituation").then(res => {
        if(res.success){
            vm.$store.commit("setContactSituation", res.result);
        }
    });


};

export default dictUtil;
